package org.yourscrum.web;

privileged aspect TeamController_Roo_Controller {
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/team", method = org.springframework.web.bind.annotation.RequestMethod.POST)    
    public java.lang.String TeamController.create(@org.springframework.web.bind.annotation.ModelAttribute("team") org.yourscrum.domain.Team team, org.springframework.validation.BindingResult result) {    
        if (team == null) throw new IllegalArgumentException("A team is required");        
        for(javax.validation.ConstraintViolation<org.yourscrum.domain.Team> constraint : javax.validation.Validation.buildDefaultValidatorFactory().getValidator().validate(team)) {        
            result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage());            
        }        
        if (result.hasErrors()) {        
            return "team/create";            
        }        
        team.persist();        
        return "redirect:/team/" + team.getId();        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/team/form", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String TeamController.createForm(org.springframework.ui.ModelMap modelMap) {    
        modelMap.addAttribute("team", new org.yourscrum.domain.Team());        
        modelMap.addAttribute("projects", org.yourscrum.domain.Project.findAllProjects());        
        return "team/create";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/team/{id}", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String TeamController.show(@org.springframework.web.bind.annotation.PathVariable("id") Long id, org.springframework.ui.ModelMap modelMap) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        modelMap.addAttribute("team", org.yourscrum.domain.Team.findTeam(id));        
        return "team/show";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/team", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String TeamController.list(org.springframework.ui.ModelMap modelMap) {    
        modelMap.addAttribute("teams", org.yourscrum.domain.Team.findAllTeams());        
        return "team/list";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(method = org.springframework.web.bind.annotation.RequestMethod.PUT)    
    public java.lang.String TeamController.update(@org.springframework.web.bind.annotation.ModelAttribute("team") org.yourscrum.domain.Team team, org.springframework.validation.BindingResult result) {    
        if (team == null) throw new IllegalArgumentException("A team is required");        
        for(javax.validation.ConstraintViolation<org.yourscrum.domain.Team> constraint : javax.validation.Validation.buildDefaultValidatorFactory().getValidator().validate(team)) {        
            result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage());            
        }        
        if (result.hasErrors()) {        
            return "team/update";            
        }        
        team.merge();        
        return "redirect:/team/" + team.getId();        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/team/{id}/form", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String TeamController.updateForm(@org.springframework.web.bind.annotation.PathVariable("id") java.lang.Long id, org.springframework.ui.ModelMap modelMap) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        modelMap.addAttribute("team", org.yourscrum.domain.Team.findTeam(id));        
        modelMap.addAttribute("projects", org.yourscrum.domain.Project.findAllProjects());        
        return "team/update";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/team/{id}", method = org.springframework.web.bind.annotation.RequestMethod.DELETE)    
    public java.lang.String TeamController.delete(@org.springframework.web.bind.annotation.PathVariable("id") java.lang.Long id) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        org.yourscrum.domain.Team.findTeam(id).remove();        
        return "redirect:/team";        
    }    
    
}
